package net.hn.hnms.biz.common.activiti.builder;

import cn.hutool.core.bean.BeanUtil;
import net.hn.hnms.biz.common.activiti.params.ProcessNodeParam;

import java.util.List;

/**
 * Created on 2022/8/4.
 *
 * @author ly
 * @desc: 流程节点定义生成器
 */
public class ProcessNodeDefinitionCreator {

    private ProcessNodeParam nodeParam = new ProcessNodeParam();

    public ProcessNodeDefinitionCreator name(String name) {
        nodeParam.setNodeName(name);
        return this;
    }

    public ProcessNodeDefinitionCreator user(String user) {
        nodeParam.addUser(user);
        return this;
    }

    public ProcessNodeDefinitionCreator users(List<String> users) {
        nodeParam.addUsers(users);
        return this;
    }

    public ProcessNodeDefinitionCreator role(String role) {
        nodeParam.addRole(role);
        return this;
    }

    public ProcessNodeDefinitionCreator roles(List<String> roles) {
        nodeParam.addRoles(roles);
        return this;
    }

    public ProcessNodeDefinitionCreator rollBackNode(String rollBackNode) {
        nodeParam.setRollBackNode(rollBackNode);
        return this;
    }

    public ProcessNodeParam build() {
        ProcessNodeParam result = new ProcessNodeParam();
        BeanUtil.copyProperties(this.nodeParam, result);
        this.nodeParam = new ProcessNodeParam();
        return result;
    }
}
